require_once('class.base.php');
$translate=array(
'en'=>array(
'confirmation_booking'=>'Thank you for your request. We will be in touch shortly.',
'booking_tailormade'=>'Tailor made trip (EN)',
'confirmation_email_subscribe'=>'Thank you for joining to Go Russia mailing list. We look forward to keeping you informed.',
'confirmation_school_presentation'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_promomaterials'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_quote'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_enquiry'=>'Thank you for your enquiry. One of our operators will call you at the specified time.',
'book'=>'book now',
'request'=>'request',
'loading'=>'Loading'
),
'es'=>array(
'confirmation_booking'=>'Thank you for your request. We will be in touch shortly.',
'booking_tailormade'=>'Tailor made trip (IN)',
'confirmation_email_subscribe'=>'Thank you for joining to Go Russia mailing list. We look forward to keeping you informed.',
'confirmation_school_presentation'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_promomaterials'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_quote'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_enquiry'=>'Thank you for your enquiry. One of our operators will call you at the specified time.',
'book'=>'book now',
'request'=>'request',
'loading'=>'Loading'
),
'us'=>array(
'confirmation_booking'=>'Thank you for your request. We will be in touch shortly.',
'booking_tailormade'=>'Tailor made trip (US)',
'confirmation_email_subscribe'=>'Thank you for joining to Go Russia mailing list. We look forward to keeping you informed.',
'confirmation_school_presentation'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_promomaterials'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_quote'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_enquiry'=>'Thank you for your enquiry. One of our operators will call you at the specified time.',
'book'=>'book now',
'request'=>'request',
'loading'=>'Loading'
),
'de'=>array(
'confirmation_booking'=>'Vielen Dank fuer Ihre Buchung. Wir werden Sie in Kuerze kontaktieren.',
'booking_tailormade'=>'Tailor made trip (DE)',
'confirmation_email_subscribe'=>'Vielen Dank fuer Ihre Anmeldung. Wir freuen uns, Sie informieren zu koennen.',
'confirmation_school_presentation'=>'Vielen Dank fuer Ihre Anfrage. Wir werden Sie in Kuerze kontaktieren.',
'confirmation_school_promomaterials'=>'Vielen Dank fuer Ihre Anfrage. Wir werden Sie in Kuerze kontaktieren.',
'confirmation_school_quote'=>'Vielen Dank fuer Ihre Anfrage. Wir werden Sie in Kuerze kontaktieren.',
'confirmation_enquiry'=>'Vielen Dank fuer Ihre Anfrage. Einer unserer Reiseberater wird Sie zu der bestimmten Zeit anrufen.',
'book'=>'buchen',
'request'=>'anfragen',
'loading'=>'Loading'
)
);
class Site extends Base {
var $rates=array();
var $menu=array();
function __construct(){
parent::__construct();
if(isset($_SESSION['message'])){
$this->assign('message',$_SESSION['message']);
unset($_SESSION['message']);
}
$this->template='pages.tpl';
}
function ajax(){
$method='ajax_'.$this->sets['item'];
if(method_exists($this, $method))
return $this->$method();
else return $this->ajax_error();
}
function ajax_subscribe_newsletter(){
global $vars, $db;
// to client
$vars['cus_email']=$_REQUEST['mail'];
$this->email_subscription_confirmation();
// to system
$subject='Join to newsletter';
$message=$this->request_table($subject);
$to=($this->sets['email'])?$this->sets['email']:'info@china-and-beyond.co.uk';
//$to='sergey.lubchenko@gmail.com';
if(!$this->send_mail($to, $subject, $message))
return $this->ajax_error();
$this->logs('Newsletter', $subject, $message);
// to sendy
return $this->ajax_success();
}
function check_site_and_redirect(){
if(!in_array($_SERVER['SERVER_NAME'],array('www.china-and-beyond.co.uk', 'www.china-und-mehr.de', 'asia', 'asia.justgorussia.co.uk'))){
//header("HTTP/1.1 302 Moved Temporarily");
header("Location: https://www.china-and-beyond.co.uk".str_replace('/us/','/en/',$_SERVER['REQUEST_URI']),TRUE,302);
exit(0);
}
}
function error_404(){
global $vars;
header("HTTP/1.0 404 Not Found");
$vars['path']=$this->sets['lang'].'/error_page.html';
return $this->main();
}
function main(){
global $vars;
global $db;
$this->check_site_and_redirect();
$this->get_path();
$page=$this->get_text_page($this->sets['section']);
$reserved=array('finder_result', 'ajax', 'call_back', 'quick_trip_founded'); // 'page_dir'
if(!$page && !in_array($this->sets['section'], $reserved)){
return $this->error_404();
}
$this->assign('item', $page);
$temp=str_replace('-','_',$this->sets['section']);
if(method_exists($this, $temp))
$this->$temp();
else $this->pages();
if(!$this->print_version){
$this->menu_list();
}
$this->display($this->template);
exit(0);
}
function get_link($str){
$temp = explode('>',$str);
$temp[0] = str_replace("'", '', $temp[0]);
$temp[0] = explode('=',$temp[0]);
$temp[0][1] = trim($temp[0][1]);
$temp[1] = explode('<',$temp[1]);
$temp[1][0] = trim($temp[1][0]);
return array('link'=>$temp[0][1], 'title'=>$temp[1][0]);
}
function menu_list(){
global $db;
$menu=$db->sql2array('select * from menu_groups where group_public="y"');
unset($this->menu);
$main_menu=array();
$mg=array();
if($menu)
foreach($menu as $m){
$mg[]=$m['group_id'];
$main_menu[$m['group_id']]=array();
}
// select first level
$sql='select page_id, page_group_id,
page_redirect, page_url,
page_dir, a.page_menu as page_title
from pages_'.$this->sets['lang'].' a
left join pages on page_id=page_link
where page_show="y" and page_parent_id=1 and page_group_id in ('.implode(',',$mg).')
order by page_group_id, page_sort_id asc';
$res=$db->sql2array($sql);
if($res && sizeof($res)>0){
$IN='';
foreach ($res as $v){
if($v['page_redirect']=='y')
$link=$v['page_url'];
elseif(strpos($v['page_title'],'get_link($v['page_title']);
$v['page_title'] = $rez['title'];
$link = $rez['link'];
}
else $link='/'.$this->sets['lang'].'/'.$v['page_dir'].'.html';
// submenu
$subar=false;
/*
if($v['page_group_id']==2){
$sql='select page_id, page_parent_id,
page_redirect, page_url,
page_dir, a.page_menu as page_title
from pages_'.$this->sets['lang'].' a
left join pages on page_id=page_link
where page_show="y" and page_parent_id='.$v['page_id'].'
order by page_sort_id, page_title';
$sub=$db->sql2array($sql);
if($sub){
$subar=array();
foreach ($sub as $s){
if($v['page_redirect']=='y')
$link=$v['page_url'];
elseif(strpos($s['page_title'],'get_link($s['page_title']);
$s['page_title'] = $rez['title'];
$l=$rez['link'];
}
else $l='/'.$this->sets['lang'].'/'.$s['page_dir'].'.html';
$subar[]=array(
'page_id'=>$s['page_id'],
'page_title'=>$s['page_title'],
'page_dir'=>$s['page_dir'],
'url'=>$l
);
}
}
}
*/
$main_menu[$v['page_group_id']][]=array(
'page_id'=>$v['page_id'],
'page_title'=>$v['page_title'],
'page_dir'=>$v['page_dir'],
'url'=>$link,
'sub'=>$subar
);
}
}
$this->assign('menu', $main_menu);
}
function upload_file($file, $path, $name){
$file_path=(strpos($path, $_SERVER['DOCUMENT_ROOT'])===false)
?$_SERVER['DOCUMENT_ROOT'].$path:$path;
if (file_exists($file['tmp_name'])){
if(move_uploaded_file($file['tmp_name'], $file_path.$name)){
chmod($file_path.$name, 0777);
return true;
}
else{
$this->errors[]="Error. File not saved. try again.";
return false;
}
}
else return false;
}
function menu_data($section=''){
$china=array(
'en'=>array(
'about_china'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_china.html',
'level'=>1,
'active'=>0
),
'why_visit_china'=>array(
'title'=>'Why Visit china',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_china.html',
'level'=>1,
'active'=>0
),
'destinations_china'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_china.html',
'level'=>1,
'active'=>0,
'destination'=>104
),
/*
'inspirations_china'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_china.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_china'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_china.html',
'level'=>1,
'active'=>0
),
'faq_china'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_china.html',
'level'=>1,
'active'=>0
),
'china'=>array(
'title'=>'china Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'china.html',
'level'=>1,
'active'=>0,
'block'=>104
)
),
'us'=>array(
'about_china'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_china.html',
'level'=>1,
'active'=>0
),
'why_visit_china'=>array(
'title'=>'Why Visit china',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_china.html',
'level'=>1,
'active'=>0
),
'destinations_china'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_china.html',
'level'=>1,
'active'=>0,
'destination'=>104
),
/*
'inspirations_china'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_china.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_china'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_china.html',
'level'=>1,
'active'=>0
),
'faq_china'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_china.html',
'level'=>1,
'active'=>0
),
'china'=>array(
'title'=>'china Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'china.html',
'level'=>1,
'active'=>0,
'block'=>104
)
),
'de'=>array(
'ueber_china'=>array(
'title'=>'Einführung',
'dir'=>'/'.$this->sets['lang'].'/ueber_china.html',
'level'=>1,
'active'=>0
),
'warum_chinareise'=>array(
'title'=>'Warum eine Chinareise',
'dir'=>'/'.$this->sets['lang'].'/warum_chinareise.html',
'level'=>1,
'active'=>0
),
'reiseziele_china'=>array(
'title'=>'Reiseziele',
'dir'=>'/'.$this->sets['lang'].'/reiseziele_china.html',
'level'=>1,
'active'=>0,
'destination'=>104
),
/*
'reiseinspirationen_china'=>array(
'title'=>'Reiseinspirationen',
'dir'=>'/'.$this->sets['lang'].'/reiseinspirationen_china.html',
'level'=>1,
'active'=>0
),
*/
'praktische_ratschlaege_china'=>array(
'title'=>'Praktische Ratschläge',
'dir'=>'/'.$this->sets['lang'].'/praktische_ratschlaege_china.html',
'level'=>1,
'active'=>0
),
'fragen_china'=>array(
'title'=>'Häufig gestellte Fragen',
'dir'=>'/'.$this->sets['lang'].'/fragen_china.html',
'level'=>1,
'active'=>0
),
'chinareisen'=>array(
'title'=>'China Reisepakete',
'dir'=>'/'.$this->sets['lang'].'/'.'chinareisen.html',
'level'=>1,
'active'=>0,
'block'=>104
)
)
);
$silk_road=array(
'en'=>array(
'about_silk_road'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_silk_road.html',
'level'=>1,
'active'=>0
),
'why_visit_kyrgyzstan'=>array(
'title'=>'Why Visit Kyrgyzstan',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_kyrgyzstan.html',
'level'=>1,
'active'=>0
),
'why_visit_uzbekistan'=>array(
'title'=>'Why Visit Uzbekistan',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_uzbekistan.html',
'level'=>1,
'active'=>0
),
'destinations_silk_road'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_silk_road.html',
'level'=>1,
'active'=>0,
'destination'=>102
),
/*
'why_visit_silk_road'=>array(
'title'=>'Why Visit Silk road',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_silk_road.html',
'level'=>1,
'active'=>0
),
'inspirations_silk_road'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_silk_road.html',
'level'=>1,
'active'=>0
),
'practicalities_silk_road'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_silk_road.html',
'level'=>1,
'active'=>0
),
'faq_silk_road'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_silk_road.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_kyrgyzstan'=>array(
'title'=>'Travel Practicalities - Kyrgyzstan',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_kyrgyzstan.html',
'level'=>1,
'active'=>0
),
'practicalities_uzbekistan'=>array(
'title'=>'Travel Practicalities - Uzbekistan',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_uzbekistan.html',
'level'=>1,
'active'=>0
),
'silk_road'=>array(
'title'=>'Silk road Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'silk_road.html',
'level'=>1,
'active'=>0,
'block'=>102
)
),
'us'=>array(
'about_silk_road'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_silk_road.html',
'level'=>1,
'active'=>0
),
'why_visit_kyrgyzstan'=>array(
'title'=>'Why Visit Kyrgyzstan',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_kyrgyzstan.html',
'level'=>1,
'active'=>0
),
'why_visit_uzbekistan'=>array(
'title'=>'Why Visit Uzbekistan',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_uzbekistan.html',
'level'=>1,
'active'=>0
),
'destinations_silk_road'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_silk_road.html',
'level'=>1,
'active'=>0,
'destination'=>102
),
/*
'inspirations_silk_road'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_silk_road.html',
'level'=>1,
'active'=>0
),
'faq_silk_road'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_silk_road.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_kyrgyzstan'=>array(
'title'=>'Travel Practicalities - Kyrgyzstan',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_kyrgyzstan.html',
'level'=>1,
'active'=>0
),
'practicalities_uzbekistan'=>array(
'title'=>'Travel Practicalities - Uzbekistan',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_uzbekistan.html',
'level'=>1,
'active'=>0
),
'silk_road'=>array(
'title'=>'Silk road Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'silk_road.html',
'level'=>1,
'active'=>0,
'block'=>102
)
),
'de'=>array(
'ueber_seidenstrasse'=>array(
'title'=>'Einführung',
'dir'=>'/'.$this->sets['lang'].'/ueber_seidenstrasse.html',
'level'=>1,
'active'=>0
),
'warum_kirgisistanreise'=>array(
'title'=>'Warum eine Kirgisistanreise',
'dir'=>'/'.$this->sets['lang'].'/'.'warum_kirgisistanreise.html',
'level'=>1,
'active'=>0
),
'warum_usbekistanreise'=>array(
'title'=>'Warum eine Usbekistanreise',
'dir'=>'/'.$this->sets['lang'].'/'.'warum_usbekistanreise.html',
'level'=>1,
'active'=>0
),
'reiseziele_seidenstrasse'=>array(
'title'=>'Reiseziele',
'dir'=>'/'.$this->sets['lang'].'/reiseziele_seidenstrasse.html',
'level'=>1,
'active'=>0,
'destination'=>102
),
/*
'warum_seidenstrassereise'=>array(
'title'=>'Warum eine Seidenstrassereise',
'dir'=>'/'.$this->sets['lang'].'/warum_seidenstrassereise.html',
'level'=>1,
'active'=>0
),
'reiseinspirationen_seidenstrasse'=>array(
'title'=>'Reiseinspirationen',
'dir'=>'/'.$this->sets['lang'].'/reiseinspirationen_seidenstrasse.html',
'level'=>1,
'active'=>0
),
'praktische_ratschlaege_seidenstrasse'=>array(
'title'=>'Praktische Ratschläge',
'dir'=>'/'.$this->sets['lang'].'/praktische_ratschlaege_seidenstrasse.html',
'level'=>1,
'active'=>0
),
'fragen_seidenstrasse'=>array(
'title'=>'Häufig gestellte Fragen',
'dir'=>'/'.$this->sets['lang'].'/fragen_seidenstrasse.html',
'level'=>1,
'active'=>0
),
*/
'praktische_ratschlaege_kirgisistan'=>array(
'title'=>'Praktische Ratschläge - Kirgisistan',
'dir'=>'/'.$this->sets['lang'].'/'.'praktische_ratschlaege_kirgisistan.html',
'level'=>1,
'active'=>0
),
'praktische_ratschlaege_usbekistan'=>array(
'title'=>'Praktische Ratschläge - Usbekistan',
'dir'=>'/'.$this->sets['lang'].'/'.'praktische_ratschlaege_usbekistan.html',
'level'=>1,
'active'=>0
),
'seidenstrassereisen'=>array(
'title'=>'Seidenstrasse Reisepakete',
'dir'=>'/'.$this->sets['lang'].'/'.'seidenstrassereisen.html',
'level'=>1,
'active'=>0,
'block'=>102
)
)
);
$mongolia=array(
'en'=>array(
'about_mongolia'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_mongolia.html',
'level'=>1,
'active'=>0
),
'why_visit_mongolia'=>array(
'title'=>'Why Visit Mongolia',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_mongolia.html',
'level'=>1,
'active'=>0
),
'destinations_mongolia'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_mongolia.html',
'level'=>1,
'active'=>0,
'destination'=>103
),
/*
'inspirations_mongolia'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_mongolia.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_mongolia'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_mongolia.html',
'level'=>1,
'active'=>0
),
'faq_mongolia'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_mongolia.html',
'level'=>1,
'active'=>0
),
'mongolia'=>array(
'title'=>'Mongolia Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'mongolia.html',
'level'=>1,
'active'=>0,
'block'=>103
)
),
'us'=>array(
'about_mongolia'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_mongolia.html',
'level'=>1,
'active'=>0
),
'why_visit_mongolia'=>array(
'title'=>'Why Visit Mongolia',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_mongolia.html',
'level'=>1,
'active'=>0
),
'destinations_mongolia'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_mongolia.html',
'level'=>1,
'active'=>0,
'destination'=>103
),
/*
'inspirations_mongolia'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_mongolia.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_mongolia'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_mongolia.html',
'level'=>1,
'active'=>0
),
'faq_mongolia'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_mongolia.html',
'level'=>1,
'active'=>0
),
'mongolia'=>array(
'title'=>'Mongolia Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'mongolia.html',
'level'=>1,
'active'=>0,
'block'=>103
)
),
'de'=>array(
'ueber_mongolei'=>array(
'title'=>'Einführung',
'dir'=>'/'.$this->sets['lang'].'/ueber_mongolei.html',
'level'=>1,
'active'=>0
),
'warum_mongoleireise'=>array(
'title'=>'Warum eine Mongoleireise',
'dir'=>'/'.$this->sets['lang'].'/warum_mongoleireise.html',
'level'=>1,
'active'=>0
),
'reiseziele_mongolei'=>array(
'title'=>'Reiseziele',
'dir'=>'/'.$this->sets['lang'].'/reiseziele_mongolei.html',
'level'=>1,
'active'=>0,
'destination'=>103
),
/*
'reiseinspirationen_mongolei'=>array(
'title'=>'Reiseinspirationen',
'dir'=>'/'.$this->sets['lang'].'/reiseinspirationen_mongolei.html',
'level'=>1,
'active'=>0
),
*/
'praktische_ratschlaege_mongolei'=>array(
'title'=>'Praktische Ratschläge',
'dir'=>'/'.$this->sets['lang'].'/praktische_ratschlaege_mongolei.html',
'level'=>1,
'active'=>0
),
'fragen_mongolei'=>array(
'title'=>'Häufig gestellte Fragen',
'dir'=>'/'.$this->sets['lang'].'/fragen_mongolei.html',
'level'=>1,
'active'=>0
),
'mongoleireisen'=>array(
'title'=>'Mongolei Reisepakete',
'dir'=>'/'.$this->sets['lang'].'/'.'mongoleireisen.html',
'level'=>1,
'active'=>0,
'block'=>103
)
)
);
$transmongol=array(
'en'=>array(
'about_transsib'=>array(
'title'=>'Einführung',
'dir'=>'/'.$this->sets['lang'].'/'.'about_transsib.html',
'level'=>1,
'active'=>0
),
'why_visit_transsib'=>array(
'title'=>'Why Visit transsib',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_transsib.html',
'level'=>1,
'active'=>0
),
'destinations_transsib'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_transsib.html',
'level'=>1,
'active'=>0,
'destination'=>101
),
/*
'inspirations_transsib'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_transsib.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_transsib'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_transsib.html',
'level'=>1,
'active'=>0
),
'faq_transsib'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_transsib.html',
'level'=>1,
'active'=>0
),
'trans_mongolian'=>array(
'title'=>'transsib Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'trans_mongolian.html',
'level'=>1,
'active'=>0,
'block'=>101
)
),
'us'=>array(
'about_transsib'=>array(
'title'=>'Introduction',
'dir'=>'/'.$this->sets['lang'].'/'.'about_transsib.html',
'level'=>1,
'active'=>0
),
'why_visit_transsib'=>array(
'title'=>'Why Visit transsib',
'dir'=>'/'.$this->sets['lang'].'/'.'why_visit_transsib.html',
'level'=>1,
'active'=>0
),
'destinations_transsib'=>array(
'title'=>'Travel Destinations',
'dir'=>'/'.$this->sets['lang'].'/'.'destinations_transsib.html',
'level'=>1,
'active'=>0,
'destination'=>101
),
/*
'inspirations_transsib'=>array(
'title'=>'Travel Inspirations',
'dir'=>'/'.$this->sets['lang'].'/'.'inspirations_transsib.html',
'level'=>1,
'active'=>0
),
*/
'practicalities_transsib'=>array(
'title'=>'Travel Practicalities',
'dir'=>'/'.$this->sets['lang'].'/'.'practicalities_transsib.html',
'level'=>1,
'active'=>0
),
'faq_transsib'=>array(
'title'=>'Frequently Asked Questions',
'dir'=>'/'.$this->sets['lang'].'/'.'faq_transsib.html',
'level'=>1,
'active'=>0
),
'trans_mongolian'=>array(
'title'=>'transsib Tour Packages',
'dir'=>'/'.$this->sets['lang'].'/'.'trans_mongolian.html',
'level'=>1,
'active'=>0,
'block'=>101
)
),
'de'=>array(
'ueber_transsib'=>array(
'title'=>'Einführung',
'dir'=>'/'.$this->sets['lang'].'/ueber_transsib.html',
'level'=>1,
'active'=>0
),
'warum_transsibreise'=>array(
'title'=>'Warum eine Transsibreise',
'dir'=>'/'.$this->sets['lang'].'/warum_transsibreise.html',
'level'=>1,
'active'=>0
),
'reiseziele_transsib'=>array(
'title'=>'Reiseziele',
'dir'=>'/'.$this->sets['lang'].'/reiseziele_transsib.html',
'level'=>1,
'active'=>0,
'destination'=>101
),
/*
'reiseinspirationen_transsib'=>array(
'title'=>'Reiseinspirationen',
'dir'=>'/'.$this->sets['lang'].'/reiseinspirationen_transsib.html',
'level'=>1,
'active'=>0
),
*/
'praktische_ratschlaege_transsib'=>array(
'title'=>'Praktische Ratschläge',
'dir'=>'/'.$this->sets['lang'].'/praktische_ratschlaege_transsib.html',
'level'=>1,
'active'=>0
),
'fragen_transsib'=>array(
'title'=>'Häufig gestellte Fragen',
'dir'=>'/'.$this->sets['lang'].'/fragen_transsib.html',
'level'=>1,
'active'=>0
),
'transsibreisen'=>array(
'title'=>'Transsib Reisepakete',
'dir'=>'/'.$this->sets['lang'].'/transsibreisen.html',
'level'=>1,
'active'=>0,
'block'=>101
)
)
);
$arr=$$section;
return $arr[$this->sets['lang']];
}
function menu_block($section=''){
$title=array(
'china'=>array(
'en'=>'China Travel Guide',
'us'=>'China Travel Guide',
'de'=>'China Reisefuhrer'
),
'mongolia'=>array(
'en'=>'Mongolia Travel Guide',
'us'=>'Mongolia Travel Guide',
'de'=>'Mongolei Reisefuhrer'
),
'silk_road'=>array(
'en'=>'Silk Road Travel Guide',
'us'=>'Silk Road Travel Guide',
'de'=>'Seidenstrasse Reisefuhrer'
),
'transmongol'=>array(
'en'=>'Trans-Mongolian Travel Guide',
'us'=>'Trans-Mongolian Travel Guide',
'de'=>'Transsib Reisefuhrer'
)
);
$blocks=array(
'china'=>array(
'map_zoom'=>3,
'map_lat'=>35,
'map_lng'=>105
),
'mongolia'=>array(
'map_zoom'=>3,
'map_lat'=>47,
'map_lng'=>102
),
'silk_road'=>array(
'map_zoom'=>3,
'map_lat'=>45,
'map_lng'=>70
),
'transmongol'=>array(
'map_zoom'=>2,
'map_lat'=>45,
'map_lng'=>80
)
);
$blocks[$section]['title']=$title[$section][$this->sets['lang']];
return $blocks[$section];
}
function pages(){
foreach(array('china', 'mongolia', 'silk_road', 'transmongol') as $block){
$arr=$this->menu_data($block);
if(array_key_exists($this->sets['section'], $arr)){
$arr[$this->sets['section']]['active']=1;
$this->assign('left_menu_list', $arr);
$this->assign('left_menu_block', $this->menu_block($block));
break;
}
}
// block tours
if(isset($arr[$this->sets['section']]['block'])){
$this->block($arr[$this->sets['section']]['block']);
}
// block desctinations
if(isset($arr[$this->sets['section']]['destination'])){
$this->destination($arr[$this->sets['section']]['destination']);
}
$this->assign('map', 1);
$this->tours_top();
}
function finder_result(){
global $vars;
$param=array(
'block'=>$vars['block'],
'days'=>@explode(';',$vars['duration']),
'price'=>@explode(';',$vars['price']),
'landmark'=>$vars['landmark'],
'inspiration'=>$vars['inspiration']
);
$this->assign('tours_array',$this->tour_block($param));
$html=$this->fetch('tour_list.tpl');
header('Content-Type: text/html; charset=windows-1252');
echo $this->php2js(array(
'error'=>0,
'errorText'=>'',
'html'=>$html
));
exit(0);
}
function tour_block($param=array()){
global $db;
$where='';
if(isset($param['block'])){
if(is_numeric($param['block'])){
$where.=' and l_block_id='.$param['block'];
}
if(is_array($param['block'])){
$where.=' and (l_block_id='.implode(' or l_block_id=',$param['block']).') ';
}
}
if(isset($param['days'])){
$where.=' and tour_days between '.$param['days'][0].' and '.$param['days'][1];
}
if(isset($param['landmark']) && !empty($param['landmark'])){
$where.=' and tour_id in (
select l_tour_id
from link_tour_highlight
where l_high_id in ('.$param['landmark'].')
)';
}
if(isset($param['inspiration']) && !empty($param['inspiration'])){
$ar=@explode(',', $param['inspiration']);
if(sizeof($ar)>0)
$where.=' and (tour_'.implode('="y" or tour_',$ar).'="y") ';
}
// block tours
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_super,
page_dir as tour_dir,
a.page_topic as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title
from link_tour_block
left join tours on l_tour_id=tour_id
left join pages_'.$this->sets['lang'].' a on tour_link=page_link
left join pages on page_id=page_link
left join season on tour_season_id=season_id
where page_show="y"
'.$where.'
order by page_sort_id asc';
$tours=$db->sql2array($sql, 'tour_id');
$tours=$this->tours_prices($tours);
$result=array();
if($tours)
foreach($tours as $t){
if(!isset($t['tour_price']))
$result[]=$t;
elseif($t['tour_price']>=$param['price'][0] &&
$t['tour_price']<=$param['price'][1])
$result[]=$t;
}
//return $this->tour_short_description($tours);
return $result;
}
function map_landmarks($block_id=104){
global $db;
$db->query('DROP TABLE IF EXISTS tmp');
$db->query('CREATE TEMPORARY TABLE tmp (high_city INT(4) DEFAULT "0" NOT NULL, high_sort int(4) DEFAULT "0" NOT NULL, UNIQUE INDEX high_city (high_city))');
$db->query('INSERT INTO tmp SELECT high_city, min(high_sort) FROM tour_highlight GROUP BY high_city');
$landmarks=$db->sql2array('
select a.l_city_id as city_id, high_img,
page_menu, page_dir, page_text
from link_block_city a
left join link_block_citypages b on a.l_city_id=b.l_city_id
left join (
select x.high_city, high_img
from tour_highlight x, tmp y
where high_show="y" and x.high_city=y.high_city and x.high_sort=y.high_sort
) c on a.l_city_id=c.high_city
left join pages_'.$this->sets['lang'].' on b.l_page_id=page_link
where
l_block_id='.$block_id.' and
l_page_id is not null and
page_show="y"
order by page_menu
', 'city_id');
$db->query('DROP TABLE tmp');
$cities=array();
if($landmarks)
foreach($landmarks as $id=>$city){
$cities[]=$id;
if(isset($this->sets['item']) && $this->sets['item']==$city['page_dir'])
$this->assign('landmark_active', $id);
$landmarks[$id]['page_link']='/'.$this->sets['lang'].'/'.$this->sets['section'].'/'.$city['page_dir'].'.html';
$landmarks[$id]['page_text']=substr(strip_tags($city['page_text']),0,180);
}
$this->assign('landmarks', $landmarks);
return $cities;
}
function map_cities($cities=array()){
global $db;
$cities=implode(',',$cities);
setDBConnection('tms');
$cities=$db->sql2array('
select city_id, city_lat, city_lng,
city_'.$this->sets['lang'].' as city_title
from tms_destination_cities
where city_id in ('.$cities.')
order by city_title');
$this->assign('destinations', $cities);
setDBConnection($this->site);
}
function destination($block_id=104){
global $db;
$cities=$this->map_landmarks($block_id);
$this->map_cities($cities);
$this->tour_destination($block_id);
$this->assign('block_id', $block_id);
// page description
if(!empty($this->sets['item']))
$this->assign('item', $this->get_text_page($this->sets['item']));
$this->template='destination.tpl';
}
function block($block_id=4){
global $db;
$param=array(
'block'=>$block_id,
'price'=>array(0,5000)
);
$this->assign('block_id', $block_id);
$this->assign('block_tours', $this->tour_block($param));
$this->assign('landmarks', $db->sql2array('
select high_id, high_title_'.$this->sets['lang'].' as high_title
from link_block_landmark
left join tour_highlight on high_id=l_high_id
where l_block_id='.$block_id.' and high_show="y"
order by l_sort, high_sort
'));
$this->template='tour_finder.tpl';
}
function index(){
global $db;
$this->tours_hot();
$this->tours_top();
// news list
/*
$sql="select news_title, news_short, news_id
from news
where news_lang='{$this->sets['lang']}' and
news_show='y' and
news_super='y'
order by news_date desc
limit 0, 4";
$this->assign('news_list', $db->sql2array($sql));
*/
$this->template='index.tpl';
}
function pdf_brochure(){
global $vars;
global $db, $translate;
require_once('admin/class.base.php');
require_once('admin/class.pdf.brochure.php');
$step=$this->sets['folders'][2];
if(!isset($step) || empty($step))
return die(header('Location: /'.$this->sets['lang'].'/pdf_brochure/pdf_brochure_step1.html'));
$pdf=new PDFBrochure();
$pdf->sets=&$this->sets;
if(!method_exists($pdf, $step))
return die(header('Location: /'.$this->sets['lang'].'/pdf_brochure/pdf_brochure_step1.html'));
$pdf->$step();
if ($pdf->smarty_vars)
foreach ($pdf->smarty_vars as $k=>$v)
$this->assign($k, $v);
$page=$this->get_text_page($this->sets['item']);
if($this->sets['item']!='pdf_brochure_step5')
$page['right'].=''.$translate[$this->sets['lang']]['loading'].'
';
$this->assign('item', $page);
$this->template=$pdf->template;
}
function tailor_made_trip(){
global $vars, $translate;
if($vars['action']=='send'){
//$this->confirm_letter($vars['E-mail'], 'tailor_made_trip');
$this->send_request($translate[$this->sets['lang']]['booking_tailormade']);
$client=array(
'title' => $vars['Title'],
'fname' => $vars['First Name'],
'lname' => $vars['Last Name'],
'email' => $vars['E-mail']
);
$this->server_mail_send(array(
'site'=>($this->siteID)?$this->siteID:1,
'lang'=>$this->sets['lang'],
'hash'=>'tailor_made_request',
'recipient'=>array(0=>$client),
'param'=>array()
));
$_SESSION['message']=$translate[$this->sets['lang']]['confirmation_booking'];
return $this->header('/'.$this->sets['lang'].'/');
}
$this->tours_top();
$this->template='tailor_made_trip.tpl';
}
function get_letter($code=''){
global $db;
$temp=$this->smarty_vars;
$t=$db->sql2rec('
select *
from letters_blank
where
lb_lang="'.$this->sets['lang'].'" and
lb_code="'.$code.'"
');
$mes=$this->fetch($t['lb_template']);
$this->smarty_vars=$temp;
return array(
'subject'=>$t['lb_subject'],
'message'=>$mes
);
}
function confirm_letter($to='', $code=''){
global $vars;
$content=$this->get_letter($code);
$this->send_mail($to, $content['subject'], $content['message']);
}
function send_request($subject){
global $vars;
global $db;
$system=array('path','action');
$text='
';
if(isset($vars))
foreach ($vars as $k=>$v)
if(!in_array($k, $system)){
$k=str_replace('_',' ',$k);
$text.="".str_replace('"','\"',$k)." | ";
$text.=(empty($v))?' ':str_replace('"','\"',$v);
$text.=" |
";
}
$ip=(isset($_COOKIE['IP']))?$_COOKIE['IP']:$_SERVER['REMOTE_ADDR'];
$text.='
IP |
'.$ip.' - view location |
';
$text.='
';
$this->send_mail($this->sets['email'], $subject, $text);
setDBConnection('tms');
$sql=sprintf("insert into letters set l_date=now(), l_type='%s', l_subject='%s', l_message='%s'",
$subject,
$db->quote_field($subject),
$db->quote($text));
$db->query($sql);
setDBConnection($this->site);
}
function call_back(){
global $translate;
global $vars;
$this->sets['email']='info@china-and-beyond.co.uk';
$this->send_request('Call back');
$text=$translate[$this->sets['lang']]['confirmation_enquiry'];
echo $this->php2js(array(
'error'=>0,
'message'=>$text
));
exit(0);
}
function kontaktieren_sie_uns(){
return $this->contact_us();
}
function contact_us(){
if($this->sets['lang']=='us'){
date_default_timezone_set('America/New_York');
$this->assign('h', date('H'));
date_default_timezone_set('Europe/London');
}elseif($this->sets['lang']=='in'){
date_default_timezone_set('Asia/Kolkata');
$this->assign('h', date('H'));
date_default_timezone_set('Europe/London');
}elseif($this->sets['lang']=='de'){
date_default_timezone_set('Europe/Berlin');
$this->assign('h', date('H'));
date_default_timezone_set('Europe/London');
}else{
$this->assign('h', gmdate('H'));
}
$this->template='pages.tpl';
}
function tour_extras($t=''){
$t=strip_tags($t);
return substr($t,0,300).'...';
}
function tour_prices($tour=false){
if(!$tour) return false;
$tours=$this->tours_prices(array($tour['tour_id']=>$tour));
return $tours[$tour['tour_id']];
}
function tours_prices($tours=array()){
global $db;
if(!is_array($tours)) return $tours;
$keys=array_keys($tours);
setDBConnection('tms');
$prices=$db->sql2array('
select min(tp_price1) as tour_price, temp_tour_id
from tms_templates_prices_'.$this->sets['lang'].'
left join tms_templates on tp_temp_id=temp_id
left join tms_templates_'.$this->sets['lang'].' on temp_id=temp_link
where
temp_show="y" and
temp_site="'.$this->site.'" and
temp_tour_id in ('.@implode(',',$keys).') and
tp_till>=now()
group by temp_tour_id
');
setDBConnection($this->site);
if($prices)
foreach($prices as $pr){
$tours[$pr['temp_tour_id']]['tour_price']=$pr['tour_price'];
}
return $tours;
}
function tours_hot(){
global $db;
//hot tours
$sql='
select a.tour_id, a.tour_days, a.tour_img, a.tour_size,
a.tour_desc_'.$this->sets['lang'].' as tour_desc,
b.page_dir as tour_dir,
b.page_menu as tour_title,
x.hot_date,
x.hot_comment as tour_extras,
c.tsp_'.$this->sets['lang'].' as tour_space,
date_format(x.hot_date, "'.$this->sets['date_format']['d.m.y'].'") as tour_date
from tour_hot x
left join tours a on x.hot_tour=a.tour_id
left join pages_'.$this->sets['lang'].' b on a.tour_link = b.page_link
left join pages e on e.page_id=b.page_link
left join tour_space c on x.hot_space = c.tsp_id
where x.hot_lang="'.$this->sets['lang'].'" and
x.hot_date>now() and
b.page_show="y"
order by hot_sort';
$hot_tours=$db->sql2array($sql, 'tour_id');
$this->assign('hot_tours', $this->tours_prices($hot_tours));
}
function tours_top(){
global $db;
// top tours
$sql='
select a.tour_id, a.tour_star, a.tour_img, a.tour_size,
a.tour_days, a.tour_extras,
a.tour_desc_'.$this->sets['lang'].' as tour_desc,
b.page_dir as tour_dir,
b.page_menu as tour_title,
concat("review_",lcase(replace(tour_ref,"-","_"))) as tour_review,
f.tour_comments
from tours a
left join pages_'.$this->sets['lang'].' b on a.tour_link = b.page_link
left join pages e on e.page_id=b.page_link
left join (
select count(*) as tour_comments, l_tour_id
from link_tour_message
group by l_tour_id
) f on a.tour_id = f.l_tour_id
where a.tour_top>0 and b.page_show="y"
order by a.tour_top';
$top_tours=$db->sql2array($sql, 'tour_id');
$this->assign('top_tours', $this->tours_prices($top_tours));
}
function tour_includes($tour_id=''){
global $db;
$res=array();
foreach(array('in','ex') as $inc){
$res[$inc]=$db->sql2array('
select inc_id,
inc_title_'.$this->sets['lang'].' as inc_title,
inc_text_'.$this->sets['lang'].' as inc_text
from link_tour_includes
left join tour_includes on l_inc_id=inc_id
where l_tour_id='.$tour_id.' and
inc_show="y" and
inc_type="'.$inc.'"
order by l_sort
');
}
return $res;
}
function tour_highlights($tour_id=''){
global $db;
$res=$db->sql2array('
select high_id, high_img,
high_title_'.$this->sets['lang'].' as high_title,
high_text_'.$this->sets['lang'].' as high_text
from link_tour_highlight
left join tour_highlight on l_high_id=high_id
where l_tour_id='.$tour_id.' and
high_show="y"
order by l_sort
');
return $res;
}
function tour_icons($tour_id=''){
global $db;
if(empty($tour_id))return false;
$icons=array();
// activity
$sql='select act_img as img,
act_title_'.$this->sets['lang'].' as title
from link_tour_activity
left join activity on l_act_id=act_id
where l_tour_id='.$tour_id;
$res=$db->sql2array($sql);
if($res) $icons=array_merge($icons, $res);
//accomodation
$sql='select place_img as img,
place_title_'.$this->sets['lang'].' as title
from link_tour_place
left join placing on l_place_id=place_id
where l_tour_id='.$tour_id;
$res=$db->sql2array($sql);
if($res) $icons=array_merge($icons, $res);
//transport
$sql='select trans_img as img,
trans_title_'.$this->sets['lang'].' as title
from link_tour_trans
left join transport on l_trans_id=trans_id
where l_tour_id='.$tour_id;
$res=$db->sql2array($sql);
if($res) $icons=array_merge($icons, $res);
//trait
$sql='select trait_img as img,
trait_title_'.$this->sets['lang'].' as title
from link_tour_trait
left join trait on l_trait_id=trait_id
where l_tour_id='.$tour_id;
$res=$db->sql2array($sql);
if($res) $icons=array_merge($icons, $res);
//season
/*
$sql='select season_img as img,
season_'.$this->sets['lang'].' as title
from tours
left join season on tour_season_id=season_id
where tour_id='.$tour_id;
$res=$db->sql2array($sql);
if($res) $icons=array_merge($icons, $res);
*/
return $icons;
}
function tour_accommodation($tour=array()){
global $vars;
global $db;
$sql='select page_link as page_id, page_topic, page_text
from link_tour_accommodation
left join pages_'.$this->sets['lang'].' on l_page_id=page_link
where l_tour_id='.$tour['tour_id'].'
order by l_sort';
$res=$db->sql2array($sql);
$this->assign('hotels', $res);
$page=$this->tour_sub_pages('accommodation');
$this->assign('accommodation', $page);
}
function tour_overview(){
global $vars;
global $db;
$page=$this->tour_sub_pages('overview');
$this->assign('overview', $page);
}
function tour_itinerary(){
global $vars;
global $db;
$page=$this->tour_sub_pages('itinerary');
$this->assign('itinerary', $page);
}
function tour_gallery(){
global $vars;
global $db;
$page=$this->tour_sub_pages('gallery');
$this->assign('gallery', $page);
}
function tour_sub_pages($sub=''){
$pages=$this->get_var('sub_pages');
if($pages)
foreach($pages as $dir=>$page)
if(strpos($dir, $sub)!==false){
return $page;
}
}
function map(){
global $vars;
global $db;
$this->assign('map', 1);
$this->template='map.tpl';
}
function tour_map_landmarks($tour_id){
global $vars, $db;
$db->query('
create temporary table tmp (
high_city int(4) default "0" not null,
high_sort int(4) default "0" not null,
unique index high_city (high_city)
)
');
$db->query('insert into tmp
select high_city, min(high_sort)
from tour_highlight
where high_city in ('.implode(',',@$vars['cities']).')
group by high_city
');
$landmarks=$db->sql2array('
select a.high_city as city_id, a.high_img,
page_menu, block_folder, page_dir, page_text
from tour_highlight a
inner join tmp t on (a.high_city=t.high_city and a.high_sort=t.high_sort)
left join link_block_citypages b on a.high_city=b.l_city_id
left join pages_'.$this->sets['lang'].' on b.l_page_id=page_link
left join link_block_city c on a.high_city=c.l_city_id
left join block on c.l_block_id=block_id
where
l_page_id is not null and
page_show="y"
order by page_menu
', 'city_id');
$db->query('drop table tmp');
$cities=array();
if($landmarks)
foreach($landmarks as $id=>$city){
$cities[]=$id;
if(isset($this->sets['item']) && $this->sets['item']==$city['page_dir'])
$this->assign('landmark_active', $id);
$landmarks[$id]['page_link']='/'.$this->sets['lang'].'/destinations_'.$city['block_folder'].'/'.$city['page_dir'].'.html';
$landmarks[$id]['page_text']=substr(strip_tags($city['page_text']),0,180);
}
$this->assign('landmarks', $landmarks);
return $cities;
}
function tour_map($tour=array()){
global $vars;
global $db;
$route=$this->sets['template']['route'];
$cities=array();
foreach($route as $city){
$cities[]=$city['city_id'];
}
$vars['cities']=$cities;
$temp=$db->sql2array('
select city_id, city_lat, city_lng,
city_'.$this->sets['lang'].' as city_title
from tms_destination_cities
where city_id in ('.@implode(',',array_unique($cities)).')
', 'city_id');
$cities=array();
foreach($route as $city){
$c=$temp[$city['city_id']];
if(is_numeric($c['city_lat']) && is_numeric($c['city_lng']))
$cities[]=$c;
}
$this->assign('tour_route', $cities);
}
function tour(){
global $vars;
global $db;
$tour_page=$this->get_text_page($this->sets['item'], 'pages');
$this->assign('item', $tour_page);
$sql='select tour_id, tour_season_id, tour_ref,
tour_dif_id, tour_distance, tour_size,
tour_days, tour_img, tour_visa, tour_link,
season_'.$this->sets['lang'].' as season_title,
dif_img, dif_title_'.$this->sets['lang'].' as dif_title
from tours
left join difficulty on tour_dif_id=dif_id
left join season on tour_season_id=season_id
where tour_link='.$tour_page['id'].'';
$tour=$db->sql2rec($sql);
$tour=$this->tour_prices($tour);
/*
// temporary check mongolia tours to turn off image gallery
$ids_tour=$db->sql2IDarray('select l_tour_id from link_tour_block where l_block_id=103');
$is_mongolia=in_array($tour['tour_id'], $ids_tour);
// visualisation
if(!$is_mongolia)
$this->tour_gallery($tour);
*/
$this->tour_gallery($tour);
$this->tour_accommodation($tour);
$this->tour_dates_prices($tour);
$this->tour_overview($tour);
$this->tour_itinerary($tour);
$this->tour_alternative($tour);
$this->tour_promoaction($tour['tour_id']);
$this->tour_map_landmarks($tour['tour_id']);
// clear template data
unset($this->sets['template']);
$this->assign('map', 1);
$this->assign('tour', $tour);
$this->assign('icons', $this->tour_icons($tour['tour_id']));
$this->assign('includes', $this->tour_includes($tour['tour_id']));
$this->assign('highlights', $this->tour_highlights($tour['tour_id']));
$this->template='tour.tpl';
}
function correct_string($data){
$data=str_replace('”','"',$data);
$data=iconv('cp1251', 'utf-8', $data);
return $data;
}
function tour_destination($block_id=1){
global $db;
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_super,
page_dir as tour_dir,
a.page_menu as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title, season_img
from tours
left join pages_'.$this->sets['lang'].' a on tour_link=page_link
left join pages on page_id=page_link
left join season on tour_season_id=season_id
where page_show="y" and
tour_id in (
select distinct l_tour_id
from link_tour_highlight
inner join tour_highlight on l_high_id=high_id
inner join link_block_city on high_city=l_city_id
where l_block_id='.$block_id.'
)
order by tour_ref asc';
$tours=$db->sql2array($sql, 'tour_id');
$tours=$this->tours_prices($tours);
//if($details) $this->tourPrepare($tours);
//else return $tours;
//$this->assign('alt_tours', $this->tour_short_description($tours));
$this->assign('destination_tours', $tours);
}
function tour_alternative($tour, $details=1){
global $db;
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_super,
page_dir as tour_dir,
a.page_topic as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title, season_img
from tour_alternative
left join tours on tour_slave=tour_id
left join pages_'.$this->sets['lang'].' a on tour_link=page_link
left join pages on page_id=page_link
left join link_tour_block on tour_id=link_tour_block.l_tour_id
left join season on tour_season_id=season_id
where page_show="y" and
tour_master='.$tour['tour_id'].'
order by tour_alternative.tour_sort asc';
$tours=$db->sql2array($sql, 'tour_id');
$tours=$this->tours_prices($tours);
//if($details) $this->tourPrepare($tours);
//else return $tours;
//$this->assign('alt_tours', $this->tour_short_description($tours));
$this->assign('alt_tours', $tours);
}
function tour_short_description($tours=array()){
if($tours)
foreach($tours as $tid=>$tour){
$temp=strip_tags($tour['tour_desc']);
if(strlen($temp)>200)
$temp=substr($temp, 0, 200).'...';
$tours[$tid]['tour_desc']=$temp;
}
return $tours;
}
function excursion_struct($res){
global $db;
$excursions=array();
if($res)
foreach($res as $rec){
$link=0;
if($rec['page_show']=='y'){
if($rec['page_redirect']=='y') $link=$rec['page_url'];
else $link='/'.$this->sets['lang'].'/'.$rec['page_dir'].'.html';
}
$excursions[]=array(
'excursion'=>$rec['excursion'],
'description'=>$rec['description'],
'image'=>$rec['img_src'],
'link'=>$link,
'title'=>$rec['title'],
);
}
return $excursions;
}
function tour_excursions($template){
global $db;
$temp=unserialize($template['temp_data']);
$result=array();
$sql='select tbs_'.$this->sets['lang'].' as excursion, img_src,
tbs_website_'.$this->sets['lang'].' as description,
a.page_menu as `title`,
page_dir,
page_url,
page_redirect,
page_show
from tour_excursions
left join tms_service_sightseeing on ex_tbs_id=tbs_id
left join pages_'.$this->sets['lang'].' a on tbs_link=page_link
left join pages_gorussia b on page_id=page_link
left join tms_service_images on (tbs_id=img_service and img_service_type="sightseeing" and img_sort=0)
where ex_tour_id='.$template['temp_tour_id'].' and tbs_public="y" and tbs_city_id=CITYID
order by tbs_sort';
if($temp['route']){
foreach($temp['route'] as $city)
if(!isset($result[$city['city_id']]))
$result[$city['city_id']]=array(
'city_id'=>$city['city_id'],
'city_title'=>$city['city_title'],
'excursion'=>$this->excursion_struct($db->sql2array(str_replace('CITYID',$city['city_id'],$sql)))
);
}
$this->assign('excursion_list', $result);
}
function tour_dates_prices($tour=array()){
global $db;
$page=$this->tour_sub_pages('dates_and_prices');
$this->assign('dates_and_prices', $page);
if(!isset($this->sets['date_format']))
$this->get_sets();
$tour_id=$tour['tour_id'];
$from='';
$best=0;
$where='';
// check cruise
$cruise=$db->sql2rec('select * from tour_cruise where cruise_tour='.$tour_id);
if ($cruise){
$from=' left join tour_cruise_shedule on td_id=cruise_date ';
$where=' and cruise_ship_'.$this->sets['lang'].'<>0';
}
$date_format=str_replace('%','',$this->sets['date_format']['d.m.Y']);
$dates=array();
$sql='select distinct td_date, td_best, td_active, tour_days
from tour_dates'.$from.'
left join tours on td_tour_id=tour_id
where td_tour_id='.$tour_id.$where.' and td_active<>"r" and td_date>now()
order by td_date';
$res=$db->sql2array($sql);
if(!$res)return;
foreach ($res as $el){
$d=explode('-',$el['td_date']);
if($el['td_best']=='y') $best=1;
$dates[]=array(
'title'=>gmdate($date_format, gmmktime(0,0,0,$d[1],$d[2],$d[0])).' - '.gmdate($date_format, gmmktime(0,0,0,$d[1],$d[2]+$el['tour_days']-1,$d[0])),
'date'=>$el['td_date'],
'best'=>$el['td_best'],
'status'=>$el['td_active']
);
}
$this->assign('best_column', $best);
setDBConnection('tms');
$arr=array();
$sql='select temp_id, temp_title, temp_desc,
tp_price1, tp_price2, tp_single_sell,
tp_from, tp_till, temp_data
from tms_templates_prices_'.$this->sets['lang'].'
left join tms_templates on tp_temp_id=temp_id
left join tms_templates_'.$this->sets['lang'].' on temp_id=temp_link
where
temp_tour_id='.$tour_id.' and
temp_site="'.$this->site.'" and
temp_show="y"
order by temp_sort, tp_from';
$res=$db->sql2array($sql);
if(!$res)return;
// tour template & map
$this->sets['template']=unserialize($res[0]['temp_data']);
$this->tour_map($tour);
// ------------
foreach ($res as $el){
if(!isset($arr[$el['temp_id']])){
$arr[$el['temp_id']]=array();
$arr[$el['temp_id']]['title']=$el['temp_title'];
$arr[$el['temp_id']]['desc']=$el['temp_desc'];
$arr[$el['temp_id']]['prices']=array();
$arr[$el['temp_id']]['dates']=array();
}
$arr[$el['temp_id']]['prices'][]=array(
'temp'=>$el['temp_id'],
'from'=>$el['tp_from'],
'till'=>$el['tp_till'],
'price1'=>$el['tp_price1'],
'price2'=>$el['tp_price2'],
'price3'=>$el['tp_single_sell']
);
}
unset($res);
foreach ($arr as $k=>$v){
$s=0;
foreach ($dates as $d){
for ($j=$s;$j=$t['from'] && $d['date']<=$t['till']){
$arr[$k]['dates'][]=array(
'title'=>$d['title'],
'date'=>$d['date'],
'best'=>$d['best'],
'status'=>$d['status'],
'template'=>$t['temp'],
'price1'=>$t['price1'],
'price2'=>$t['price2'],
'price3'=>$t['price3']
);
$s=$j;
$j=10000000;
}
}
}
unset($arr[$k]['prices']);
}
unset($dates);
$this->assign('prices', $arr);
setDBConnection($this->site);
}
function itinerary_short($data){
global $translate, $vars, $db;
if (!function_exists('sortrec')){
function sortrec($a, $b) {
if ($a['sort'] == $b['sort']) return 0;
return ($a['sort'] < $b['sort']) ? -1 : 1;
}
}
$im=0;
$template=unserialize($data['temp_data']);
$w=$data['temp_start']; // день начала тура
$d=0; $td=-1;// номер дня
$route=array(); // маршрут
for($i=0;$iget_city_name($temp['city_id'], $this->sets['lang']);
if($temp['content'])
foreach ($temp['content'] as $k=>$day){
if($d!=$td){
$day_title=($data['temp_weekdays']!='y')?'':$this->week_days[$this->sets['lang']][(($d+$w)%7)];
$route[]=array(
'day_num'=>($d+1),
'day_title'=>$day_title,
'city'=>$city_title,
'day_desc'=>$translate[$this->sets['lang']]['day'].' '.($d+1).((empty($day_title))?'':(' - '.$day_title)).' - '.$city_title,
'content'=>array()
);
}
else{
$route[sizeof($route)-1]['city'].=' - '.$city_title;
}
$td=$d;
$sort=array();
if(isset($day['sightseeing']) && sizeof($day['sightseeing'])>0){
foreach ($day['sightseeing'] as $g=>$m){
//echo $m;
//echo $this->sets['lang'];
if(isset($m['id']) && $m['id']>0){
$sql='select tbs_id as id, tbs_'.$this->sets['lang'].' as title
from tms_service_sightseeing_advanced
left join tms_service_sightseeing on sightseeing=tbs_id
where id='.$m['id'];
$serv=$db->sql2rec($sql);
$title=$serv['title'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'images'=>$this->service_images('sightseeing', $serv['id']),
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
$im++;
}
}
if(isset($day['transfer']) && sizeof($day['transfer'])>0){
foreach ($day['transfer'] as $g=>$m){
if(isset($m['id']) && $m['id']>0){
$sql='select tbtr_id as id, tbtr_'.$this->sets['lang'].' as title
from tms_service_transfers_advanced
left join tms_service_transfers on transfer=tbtr_id
where id='.$m['id'];
$serv=$db->sql2rec($sql);
$title=$serv['title'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'images'=>$this->service_images('transfer', $serv['id']),
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['theatre']) && sizeof($day['theatre'])>0){
foreach ($day['theatre'] as $g=>$m){
if(isset($m['id']) && $m['id']>0){
$sql='select tbt_id as id, tbt_'.$this->sets['lang'].' as title
from tms_service_theatres_advanced
left join tms_service_theatres on theatres=tbt_id
where id='.$m['id'];
$serv=$db->sql2rec($sql);
$title=$serv['title'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'images'=>$this->service_images('thearte', $serv['id']),
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['package']) && sizeof($day['package'])>0){
foreach ($day['package'] as $g=>$m){
$id=0;
if(isset($m['id']) && $m['id']>0)$id=$m['id'];
elseif(isset($m['link']) && $m['link']>0)$id=$m['link'];
if($id>0){
$sql='select tbp_id as id, tbp_'.$this->sets['lang'].' as title
from tms_service_package
where tbp_id='.$id;
$serv=$db->sql2rec($sql);
$title=$serv['title'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'images'=>$this->service_images('package', $serv['id']),
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['comment']) && sizeof($day['comment'])>0){
foreach ($day['comment'] as $g=>$m){
$id=0;
if(isset($m['id']) && $m['id']>0) $id=$m['id'];
if($id>0){
$sql='select tbc_'.$this->sets['lang'].' as title
from tms_service_comment
where tbc_id='.$id;
$title=$db->sql2value($sql);
}
else $title=$m['title'];
$sort[]=array(
'title'=>$title,
'sort'=>((isset($m['sort']))?$m['sort']:0)
);
}
}
usort($sort, 'sortrec');
$tdd=sizeof($route)-1;
if($sort && sizeof($sort)>0)
foreach($sort as $el)
$route[$tdd]['content'][]=$el;
if($k<$temp['city_days']-1) $d++;
}
$ddd=0;
if(isset($temp['intercity']) && sizeof($temp['intercity'])>0){
foreach ($temp['intercity'] as $k=>$v){
if(isset($v['id']) && $v['id']>0){
$sql='select tbis_id as id, tbis_transport,
city_'.$this->sets['lang'].' as city,
tbis_'.$this->sets['lang'].' as title
from tms_service_intercity_advanced
left join tms_service_intercity on intercity=tbis_id
left join tms_destination_cities on tbis_to=city_id
where id='.$v['id'];
$tres=$db->sql2rec($sql);
if($this->sets['lang']=='de'){
switch($tres['tbis_transport']){
case 1: $title='Abfahrt nach '.$tres['city'].' mit einem '.$tres['title']; break;
case 2: $title='Flug nach '.$tres['city']; break;
case 3: $title='Transfer nach '.$tres['city'].' mit einem '.$tres['title']; break;
case 7: $title='Kreuzfahrt nach '.$tres['city']; break;
default: $title='Abfahrt nach '.$tres['city'];
}
}
else{
switch($tres['tbis_transport']){
case 1: $title='Departure to '.$tres['city'].' by '.$tres['title']; break;
case 2: $title='Flight to '.$tres['city']; break;
case 3: $title='Transfer to '.$tres['city'].' by '.$tres['title']; break;
case 7: $title='Cruising to '.$tres['city']; break;
default: $title='Departure to '.$tres['city'];
}
}
}
else $title=$v['short_title'];
$route[$tdd]['content'][]=array(
'title'=>$title,
'images'=>$this->service_images('intercity', $tres['id']),
'sort'=>sizeof($route[$tdd]['content'])
);
if($v['days']>$ddd)$ddd=$v['days'];
}
}
else $ddd=1;
$d+=$ddd;
}
$this->assign('template_short', $route);
}
function itinerary_full($data){
global $vars;
global $db;
$w=$data['temp_start']; // день начала тура
$template=unserialize($data['temp_data']);
$d=0; $td=-1; // номер дня
$route=array(); // маршрут
for($i=0;$iget_city_name($temp['city_id'], $this->sets['lang']);
if($temp['content'])
foreach ($temp['content'] as $k=>$day){
if($d!=$td){
$day_title=(($data['temp_weekdays']!='y')?'':$this->week_days[$this->sets['lang']][(($d+$w)%7)]);
$route[]=array(
'day_num'=>($d+1),
'day_title'=>$day_title,
'city'=>$city_title,
'content'=>array()
);
}
else{
$route[sizeof($route)-1]['city'].=' - '.$city_title;
}
$sort=array();
$td=$d;
if(isset($day['sightseeing']) && sizeof($day['sightseeing'])>0){
foreach ($day['sightseeing'] as $g=>$m){
if(isset($m['id']) && $m['id']>0){
$sql='select tbs_'.$this->sets['lang'].',
tbs_itinerary_'.$this->sets['lang'].' as tbs_itinerary
from tms_service_sightseeing_advanced
left join tms_service_sightseeing on sightseeing=tbs_id
where id='.$m['id'];
$ttemp=$db->sql2rec($sql);
$title=''.$ttemp['tbs_'.$this->sets['lang']].'
'.$ttemp['tbs_itinerary'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['transfer']) && sizeof($day['transfer'])>0){
foreach ($day['transfer'] as $g=>$m){
if(isset($m['id']) && $m['id']>0){
$sql='select tbtr_'.$this->sets['lang'].',
tbtr_itinerary_'.$this->sets['lang'].' as tbtr_itinerary
from tms_service_transfers_advanced
left join tms_service_transfers on transfer=tbtr_id
where id='.$m['id'];
$ttemp=$db->sql2rec($sql);
$title=''.$ttemp['tbtr_'.$this->sets['lang']].'
'.$ttemp['tbtr_itinerary'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['theatre']) && sizeof($day['theatre'])>0){
foreach ($day['theatre'] as $g=>$m){
if(isset($m['id']) && $m['id']>0){
$sql='select tbt_'.$this->sets['lang'].',
tbt_itinerary_'.$this->sets['lang'].' as tbt_itinerary
from tms_service_theatres_advanced
left join tms_service_theatres on theatres=tbt_id
where id='.$m['id'];
$ttemp=$db->sql2rec($sql);
$title=''.$ttemp['tbtr_'.$this->sets['lang']].'
'.$ttemp['tbtr_itinerary'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['package']) && sizeof($day['package'])>0){
foreach ($day['package'] as $g=>$m){
$id=0;
if(isset($m['id']) && $m['id']>0)$id=$m['id'];
elseif(isset($m['link']) && $m['link']>0)$id=$m['link'];
if($id>0){
$sql='select tbp_'.$this->sets['lang'].',
tbp_itinerary_'.$this->sets['lang'].' as tbp_itinerary
from tms_service_package
where tbp_id='.$id;
$ttemp=$db->sql2rec($sql);
$title=''.$ttemp['tbp_'.$this->sets['lang']].'
'.$ttemp['tbp_itinerary'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
if(isset($day['comment']) && sizeof($day['comment'])>0){
foreach ($day['comment'] as $g=>$m){
$id=0;
if(isset($m['id']) && $m['id']>0)$id=$m['id'];
if($id>0){
$sql='select tbc_'.$this->sets['lang'].',
tbc_itinerary_'.$this->sets['lang'].' as tbc_itinerary
from tms_service_comment
where tbc_id='.$id;
$ttemp=$db->sql2rec($sql);
$title=''.$ttemp['tbc_'.$this->sets['lang']].'
'.$ttemp['tbc_itinerary'];
}
else $title=$m['short_title'];
$sort[]=array(
'title'=>$title,
'sort'=>(!isset($m['sort']))?0:$m['sort']
);
}
}
usort($sort, 'sortrec');
$tdd=sizeof($route)-1;
foreach($sort as $el)
$route[$tdd]['content'][]=$el;
if($k<$temp['city_days']-1) $d++;
}
$ddd=0;
if(isset($temp['intercity']) && sizeof($temp['intercity'])>0){
foreach ($temp['intercity'] as $k=>$v){
if(isset($v['id']) && $v['id']>0){
$sql='select tbis_'.$this->sets['lang'].',
tbis_itinerary_'.$this->sets['lang'].' as tbis_itinerary
from tms_service_intercity_advanced
left join tms_service_intercity on intercity=tbis_id
where id='.$v['id'];
$temp=$db->sql2rec($sql);
$title=''.$temp['tbis_'.$this->sets['lang']].'
'.$temp['tbis_itinerary'];
}
else $title=$v['short_title'];
$route[$tdd]['content'][]=array(
'title'=>$title,
'sort'=>sizeof($route[$tdd]['content'])
);
if($v['days']>$ddd)$ddd=$v['days'];
}
}
else $ddd=1;
$d+=$ddd;
}
$this->assign('template_full', $route);
}
function subscribe_newletter(){
global $db, $translate;
global $vars;
$subject='Join to newsletter';
$message="
Join to newsletter
Email: {$vars['email']}
Language: {$this->sets['lang']}
";
$this->send_mail($this->sets['email'], $subject, $message);
$sql=sprintf("insert into letters set l_date='%s', l_subject='%s', l_message='%s'",
gmdate('Y-m-d'),
$db->quote_field($subject),
$db->quote($message));
$db->query($sql);
die("document.forms['search_form'].newsletter.value='';alert('{$translate[$this->sets['lang']]['confirmation_email_subscribe']}'); ");
}
function newsdesk(){
global $db;
global $vars;
if($this->sets['item']!='')
$temp=explode('_', $this->sets['item']);
else $temp=array(0=>'page', 1=>1);
if($temp && $temp[0]=='news'){
$r=$db->sql2array('
select news_title, news_full,
news_description, news_keywords,
date_format(news_date, "%d.%m.%Y") as news_date
from news
where news_show="y" and
news_lang="'.$this->sets['lang'].'" and
news_id='.$temp[1]
);
if($r && sizeof($r)>0){
$this->assign('item', $r[0]);
$this->smarty_vars['item']['description']=$r[0]['news_description'];
$this->smarty_vars['item']['keywords']=$r[0]['news_keywords'];
$this->smarty_vars['item']['page_title']=$r[0]['news_title'];
$this->smarty_vars['item']['title']=$r[0]['news_title'];
$this->smarty_vars['item']['date']=$r[0]['news_date'];
$this->smarty_vars['item']['text']=$r[0]['news_full'];
$this->template='news_view.tpl';
}
else{
$this->sets['item']='';
return $this->newsdesk();
}
}
else{
$vars['p_id']=$temp[1];
$count=$this->sets['news_per_page']; $start=($vars['p_id']-1)*$count;
$news_res=$db->sql2array("select count(news_id) as kolvo from news where news_lang='{$this->sets['lang']}'");
$this->pages_counter($vars['p_id'], $news_res[0]['kolvo'], $count);
$r=$db->sql2array('select news_id, news_title, news_short, date_format(news_date, "%d.%m.%Y") as news_data from news where news_show="y" and news_lang="'.$this->sets['lang'].'" order by news_date desc limit '.$start.', '.$count);
$this->assign('news_list', $r);
$this->template='news_list.tpl';
}
}
/*
function pages_counter($current_page, $total, $per_page){
$pages_display=10;
$pages=floor($total/$per_page);
$pages+=($total%$per_page==0)?0:1;
$page_list=array();
$start=1; $finish=$pages;
// if($pages<=$pages_display){$start=1; $finish=$pages;}
// else{
// if($current_page<=floor($pages_display/2)){$start=1; $finish=$pages_display;}
// elseif($pages-$current_page<=floor($pages_display/2)){$start=$pages-$pages_display+1; $finish=$pages;}
// else {$start=$current_page-floor($pages_display/2); $finish=$start+$pages_display-1;}
// }
for($i=$start;$i<=$finish;$i++) $page_list[]=$i;
if($current_page>1)$previous=$current_page-1; else $previous=-1;
if($current_page<$pages)$next=$current_page+1; else $next=-1;
if(sizeof($page_list)<2)$page_list=false;
$this->assign('cur_page', $current_page);
$this->assign('pages', $page_list);
$this->assign('next', $next);
$this->assign('previous', $previous);
}
*/
function guestbook_lang(){
global $db;
global $vars;
switch($vars['action']){
case 'save':
$sql=$db->sql2var("select a_code as code from antibot where a_key='{$vars['key']}'");
if($GLOBALS['code']==strtolower($vars['code'])){
$vars['text']=nl2br($vars['text']);
$sql=sprintf("insert into messages set m_date='%s', m_text='%s', m_key='', m_name='%s', m_tour=%d, m_lang='%s', m_period='%s'",
gmdate("Y-m-d"), $db->quote_field($vars['text']), $db->quote_field($vars['name']),
$vars['tour_id'], $this->sets['lang'], $db->quote_field($vars['period']));
$db->query($sql);
if($vars['tour_id']==0){
$db->query(sprintf("insert into tour_other(to_m_id, to_tour) values(%d, '%s')",
$db->insert_id(),
$db->quote_field($vars['other']))
);
}
$date=gmdate('Y-m-d');
$db->sql2var("delete from antibot where a_key='{$vars['key']}' or a_date<'$date'");
}
$vars['action']='list';
return $this->guestbook_lang();
break;
case 'search_region':
$mes_res=$db->sql2value("select count(m_id) as kolvo from messages, link_region_message where l_m_id=m_id and l_region_id={$vars['region']} and m_lang='{$this->sets['lang']}'and m_flag='y'");
$sql='
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours, link_region_message
where l_m_id=m_id and l_region_id='.$vars['region'].' and m_tour=tour_id and page_link=tour_link and m_lang="'.$this->sets['lang'].'" and m_flag="y"'.$str_t.')
union
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
to_tour as m_tour
from messages, tour_other, link_region_message
where l_m_id=m_id and l_region_id='.$vars['region'].' and m_id=to_m_id and m_lang="'.$this->sets['lang'].'" and m_flag="y"'.$str_o.')
order by m_date desc
limit ';
$this->assign('val_reg', $vars['region']);
break;
case 'search_ref':
$mes_res=$db->sql2value("select count(m_id) as kolvo from messages, tours where tour_ref='{$vars['ref']}' amd m_tour=tour_is and m_lang='{$this->sets['lang']}'and m_flag='y'");
$sql='
select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours where tour_ref="'.$vars['ref'].'" and m_tour=tour_id and page_link=tour_link and m_lang="'.$this->sets['lang'].'" and m_flag="y"
order by m_date desc
limit ';
$this->assign('val_ref', $vars['ref']);
break;
case 'search_tour':
$arr=explode(' ', $vars['tour']);
$str_t=''; $str_o='';
if($arr && sizeof($arr)>0)
foreach ($arr as $i){
$el=trim($i, "\x00..\x20");
if($el!='' && strlen($el)>2){
$str_t.=" or page_title_{$this->sets['lang']} like '%$el%'";
$str_o.=" or to_tour like '%$el%'";
}
}
if($str_t==''){
$vars['action']='list';
return $this->guestbook_lang();
}
else{
$str_t=' and ('.substr($str_t, 4).')';
$str_o=' and ('.substr($str_o, 4).')';
}
$mes_res=$db->sql2value("select count(m_id) from messages, tours, pages_'.$this->sets['lang'].' where page_link=tour_link and tour_id=m_tour and m_lang='{$this->sets['lang']}' and m_flag='y'$str_t");
$mes_res+=$db->sql2value("select count(m_id) from messages, tour_other where to_m_id=m_id and m_lang='{$this->sets['lang']}' and m_flag='y'$str_o");
$sql='
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours where m_tour=tour_id and page_link=tour_link and m_lang="'.$this->sets['lang'].'" and m_flag="y"'.$str_t.')
union
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
to_tour as m_tour
from messages, tour_other where m_id=to_m_id and m_lang="'.$this->sets['lang'].'" and m_flag="y"'.$str_o.')
order by m_date desc
limit ';
$this->assign('val_tour', $vars['tour']);
break;
default:
$lang=$this->sets['lang'];
if($lang=='us' || $lang=='en' || $lang=='in')
$lang=' in ("en", "us", "in") ';
else $lang='="'.$lang.'" ';
$mes_res=$db->sql2value('
select count(m_id) from messages
where m_lang'.$lang.' and m_flag="y"
');
//
if($this->sets['lang']=='us' || $this->sets['lang']=='en' || $this->sets['lang']=='in'){
$sql='
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
page_title as m_tour
from messages
left join tours on m_tour=tour_id
left join pages_en on tour_link=page_link
where m_tour>0 and m_lang="en" and m_flag="y")
union
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
page_title as m_tour
from messages
left join tours on m_tour=tour_id
left join pages_us on tour_link=page_link
where m_tour>0 and m_lang="us" and m_flag="y")
union
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
page_title as m_tour
from messages
left join tours on m_tour=tour_id
left join pages_in on tour_link=page_link
where m_tour>0 and m_lang="in" and m_flag="y")
union
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
to_tour as m_tour
from messages
left join tour_other on m_id=to_m_id
where m_tour=0 and m_lang'.$lang.' and m_flag="y")
order by m_date desc
limit ';
/*
*/
}
else{
$sql='
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
page_title as m_tour
from messages
left join tours on m_tour=tour_id
left join pages_'.$this->sets['lang'].' on tour_link=page_link
where m_tour>0 and m_lang'.$lang.' and m_flag="y")
union
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d") as m_dd,
date_format(m_date, "%c") as m_mm,
date_format(m_date, "%Y") as m_yy,
m_period, m_flag, m_lang,
to_tour as m_tour
from messages
left join tour_other on m_id=to_m_id
where m_tour=0 and m_lang'.$lang.' and m_flag="y")
order by m_date desc
limit ';
}
$vars['action']='list';
}
$this->assign('val_action', $vars['action']);
//form search
$sql1='select distinct tour_ref from tours
where tour_id in (select distinct l_tour_id from link_tour_block)
order by tour_ref';
$this->assign('refli', $db->sql2array($sql1));
$this->assign('regli', $db->sql2array('select region_id, region_title_'.$this->sets['lang'].' as region_title from region order by region_title'));
//form add
$sql1='select tour_id, page_title as tour_title
from tours left join pages_'.$this->sets['lang'].' on tour_link=page_link
where tour_id in (select distinct l_tour_id from link_tour_block)
order by tour_title';
// and
$this->assign('tgb', $db->sql2array($sql1));
$pid=($vars['pid']==0)?1:$vars['pid'];
if($pid>$mes_res)$pid=1;
$count=10; $start=($pid-1)*$count;
$this->pages_counter($pid, $mes_res, $count);
$sql.=$start.', '.$count;
$res=$db->sql2array($sql);
if($res)
foreach($res as $k=>$v){
$res[$k]['m_from']=$v['m_dd'].' '.$this->months[$this->sets['lang']][$v['m_mm']-1].' '.$v['m_yy'];
unset($res[$k]['m_dd']);
unset($res[$k]['m_mm']);
unset($res[$k]['m_yy']);
}
$this->assign('meslist', $res);
$key=$this->get_pass();
$code=$this->get_pass();
$db->query(sprintf("insert into antibot(a_key, a_code, a_date) values('%s', '%s', '%s')", $db->quote($key), $db->quote($code), $db->quote(gmdate("Y-m-d"))));
$this->assign('key', $key);
$this->template='guestbook.tpl';
}
function guestbook(){
global $db;
global $vars;
return $this->guestbook_lang();
switch($vars['action']){
case 'save':
$sql=$db->sql2var("select a_code as code from antibot where a_key='{$vars['key']}'");
if($GLOBALS['code']==strtolower($vars['code'])){
$vars['text']=nl2br($vars['text']);
$sql=sprintf("insert into messages set m_date='%s', m_text='%s', m_key='', m_name='%s', m_tour=%d, m_lang='%s', m_period='%s'",
gmdate("Y-m-d"), $db->quote_field($vars['text']), $db->quote_field($vars['name']),
$vars['tour_id'], $this->sets['lang'], $db->quote_field($vars['period']));
$db->query($sql);
if($vars['tour_id']==0){
$db->query(sprintf("insert into tour_other(to_m_id, to_tour) values(%d, '%s')",
$db->insert_id(),
$db->quote_field($vars['other']))
);
}
$date=gmdate('Y-m-d');
$db->sql2var("delete from antibot where a_key='{$vars['key']}' or a_date<'$date'");
}
$vars['action']='list';
return $this->guestbook();
break;
case 'search_region':
$mes_res=$db->sql2value("select count(m_id) as kolvo from messages, link_region_message where l_m_id=m_id and l_region_id={$vars['region']} and m_flag='y'");
$sql='
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d.%m.%Y") as m_from,
m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours, link_region_message where l_m_id=m_id and l_region_id='.$vars['region'].' and m_tour=tour_id and page_link=tour_link and m_flag="y"'.$str_t.')
union
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
to_tour as m_tour
from messages, tour_other, link_region_message where l_m_id=m_id and l_region_id='.$vars['region'].' and m_id=to_m_id and m_flag="y"'.$str_o.')
order by m_date desc
limit ';
$this->assign('val_reg', $vars['region']);
break;
case 'search_ref':
$mes_res=$db->sql2value("select count(m_id) as kolvo from messages, tours where tour_ref='{$vars['ref']}' amd m_tour=tour_is and m_flag='y'");
$sql='
select m_id, m_text, m_name, m_date,
date_format(m_date, "%d.%m.%Y") as m_from,
m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours where tour_ref="'.$vars['ref'].'" and m_tour=tour_id and page_link=tour_link and m_flag="y"
order by m_date desc
limit ';
$this->assign('val_ref', $vars['ref']);
break;
case 'search_tour':
$arr=explode(' ', $vars['tour']);
$str_t=''; $str_o='';
if($arr && sizeof($arr)>0)
foreach ($arr as $i){
$el=trim($i, "\x00..\x20");
if($el!='' && strlen($el)>2){
$str_t.=" or page_title_{$this->sets['lang']} like '%$el%'";
$str_o.=" or to_tour like '%$el%'";
}
}
if($str_t==''){
$vars['action']='list';
return $this->guestbook();
}
else{
$str_t=' and ('.substr($str_t, 4).')';
$str_o=' and ('.substr($str_o, 4).')';
}
$mes_res=$db->sql2value("select count(m_id) from messages, tours, pages_'.$this->sets['lang'].' where page_link=tour_link and tour_id=m_tour and m_flag='y'$str_t");
$mes_res+=$db->sql2value("select count(m_id) from messages, tour_other where to_m_id=m_id and m_flag='y'$str_o");
$sql='
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d.%m.%Y") as m_from,
m_period, m_flag, m_lang,
page_title as m_tour
from messages, pages_'.$this->sets['lang'].', tours where m_tour=tour_id and page_link=tour_link and m_flag="y"'.$str_t.')
union
(select m_id, m_text, m_name, m_date, date_format(m_date, "%d.%m.%Y") as m_from, m_period, m_flag, m_lang,
to_tour as m_tour
from messages, tour_other where m_id=to_m_id and m_flag="y"'.$str_o.')
order by m_date desc
limit ';
$this->assign('val_tour', $vars['tour']);
break;
default:
$mes_res=$db->sql2value('
select count(m_id) from messages
where m_flag="y"
');
//
$sql='
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d.%m.%Y") as m_from,
m_period, m_flag, m_lang,
page_title as m_tour
from messages
left join tours on m_tour=tour_id
left join pages_'.$this->sets['lang'].' on tour_link=page_link
where m_flag="y")
union
(select m_id, m_text, m_name, m_date,
date_format(m_date, "%d.%m.%Y") as m_from,
m_period, m_flag, m_lang,
to_tour as m_tour
from messages
left join tour_other on m_id=to_m_id
where m_flag="y")
order by m_date desc
limit ';
$vars['action']='list';
}
$this->assign('val_action', $vars['action']);
//form search
$sql1='select distinct tour_ref from tours
where tour_id in (select distinct l_tour_id from link_tour_block)
order by tour_ref';
$this->assign('refli', $db->sql2array($sql1));
$this->assign('regli', $db->sql2array('select region_id, region_title_'.$this->sets['lang'].' as region_title from region order by region_title'));
//form add
$sql1='select tour_id, page_menu as tour_title
from tours left join pages_'.$this->sets['lang'].' on tour_link=page_link
where tour_id in (select distinct l_tour_id from link_tour_block)
order by tour_title';
// and
$this->assign('tgb', $db->sql2array($sql1));
$pid=($vars['pid']==0)?1:$vars['pid'];
if($pid>$mes_res)$pid=1;
$count=10; $start=($pid-1)*$count;
$this->pages_counter($pid, $mes_res, $count);
$sql.=$start.', '.$count;
$this->assign('meslist', $db->sql2array($sql));
$key=$this->get_pass();
$code=$this->get_pass();
$db->query(sprintf("insert into antibot(a_key, a_code, a_date) values('%s', '%s', '%s')", $db->quote($key), $db->quote($code), $db->quote(gmdate("Y-m-d"))));
$this->assign('key', $key);
$this->template='guestbook.tpl';
}
function do_search(){
global $db;
if(isset($this->sets['item']) && $this->sets['item']!=''){
$result=array();
$arr=explode(' ', $this->sets['item']);
$str_p=''; $str_t=''; $str_r='';
foreach ($arr as $i){
$el=trim($i, "\x00..\x20");
if($el!=''){
if($str_p==''){
$str_p="page_text like '%$el%'";
$str_t="page_title like '%$el%'";
$str_r="page_add like '%$el%'";
}
else {
$str_p.=" and page_text like '%$el%'";
$str_t.=" and page_title like '%$el%'";
$str_r.=" and page_add like '%$el%'";
}
}
}
$sql='select distinct
page_title,
page_dir
from pages_'.$this->sets['lang'].'
left join pages_gorussia on page_id=page_link
where page_priority<>0 and (('.$str_t.') or ('.$str_p.') or ('.$str_r.'))
order by page_priority asc';
$res=$db->sql2array($sql);
if($res && sizeof($res)>0)
foreach ($res as $i)
$result[]=array('title'=>$i['page_title'], 'link'=>'http://'.$_SERVER['SERVER_NAME'].'/'.$this->sets['lang'].'/'.$i['page_dir'].'.html');
$this->assign('search_result', $result);
}
else $this->assign('search_result', false);
$this->template='search.tpl';
}
function customer_frame(){
global $vars;
$customer_path=str_replace('customer/', '', $vars['path']);
$this->assign('customer_path', $customer_path);
$this->template='customer.tpl';
}
function customer(){
global $vars;
$vars['path']=$vars['path'].'.html';
$customer_path=str_replace('customer.html', 'customer/', $vars['path']);
if(empty($customer_path)) $customer_path='/'.$this->sets['lang'].'/customer/';
$customer_path='https://'.str_replace('www.', 'customer.', $_SERVER['HTTP_HOST']).'/'.$customer_path;
require_once 'class.cabinet.php';
$cabinet=new CustomerCabinet();
if(isset($vars['do']) && $vars['do']=='html'){
$html=$cabinet->process_block($customer_path);
die($html);
}
else{
$html=$cabinet->process_page($customer_path);
}
require_once 'class.cabinet.php';
$cabinet=new CustomerCabinet();
if(isset($vars['do']) && $vars['do']=='html'){
$html=$cabinet->process_block($customer_path);
die($html);
}
else{
$html=$cabinet->process_page($customer_path);
}
$this->assign('customer_html', $html);
$this->template='customer_noframe.tpl';
}
function customer_old(){
global $vars;
require_once('class.customer.php');
$user=new CustomerAccount();
$user->smarty_vars=&$this->smarty_vars;
$user->template=&$this->template;
$user->errors=&$this->errors;
$user->sets=&$this->sets;
$method=$this->sets['item'];
if(method_exists($user, $method))
$user->$method();
else $user->undefined();
}
function reisen_schnell_finden(){
return $this->quick_trip_finder();
}
function quick_trip_finder(){
global $db;
global $vars;
$landmarks=array();
$temp=$db->sql2array('
select high_id, high_title_'.$this->sets['lang'].' as high_title, l_block_id
from link_block_landmark
left join tour_highlight on high_id=l_high_id
where high_show="y"
order by high_title
'); //l_sort, high_sort
if($temp)
foreach($temp as $t){
$landmarks[$t['l_block_id']][]=$t;
}
$param=array(
'block'=>$vars['block'],
'inspiration'=>$vars['inspiration'],
'price'=>array(0,5000)
);
$this->assign('block_tours', $this->tour_block($param));
$this->assign('inspiration', $vars['inspiration']);
$this->assign('landmarks', $landmarks);
$this->template='quick_trip_finder.tpl';
}
function quick_trip_founded(){
global $db;
global $vars;
if(isset($vars['block']) && !empty($vars['block']))
$temp=@explode(',',$vars['block']);
else $temp=false;
$param=array(
'block'=>$temp,
'days'=>@explode(';',$vars['duration']),
'price'=>@explode(';',$vars['price']),
'landmark'=>$vars['landmark'],
'inspiration'=>$vars['inspiration']
);
$this->assign('tours_array',$this->tour_block($param));
$html=$this->fetch('tour_list.tpl');
echo $this->php2js(array(
'error'=>0,
'errorText'=>'',
'html'=>$html
));
exit(0);
}
function tour_promoaction($tour_id){
global $db;
// Promo action
$promo=array();
$sql='select *
from tour_promotion
where promo_show="y" and
promo_lang="'.$this->sets['lang'].'" and
promo_tours like "%'.$tour_id.'%"
order by promo_id asc';
$res_promo=$db->sql2array($sql);
if($res_promo)
foreach($res_promo as $r){
$rr=@explode(', ', $r['promo_tours']);
if(in_array($tour_id, $rr))
$promo[]=$r['promo_text'];
}
$this->assign('promo', $promo);
}
function tour_promotion(){
global $db;
global $vars;
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_price1'.$this->curfield.' as price, tour_super,
page_dir,
page_title as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title, season_img
from tours left join pages_'.$this->sets['lang'].' on tour_link=page_link
left join pages_gorussia on page_id=page_link
left join link_tour_block on tour_id=link_tour_block.l_tour_id
left join link_tour_activity on tour_id=link_tour_activity.l_tour_id
left join season on tour_season_id=season_id
where page_show="y" and
tour_promotion="y"
order by page_sort_id asc';
$this->tourPrepare($db->sql2array($sql, 'tour_id'));
$this->template='tour_promotion.tpl';
}
function tour_search(){
global $db;
global $vars;
switch($this->sets['item']){
case 'activity':
if(isset($this->sets['folders'][3]) && is_numeric($this->sets['folders'][3])){
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_price1'.$this->curfield.' as price, tour_super,
page_dir,
page_title as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title, season_img
from tours inner join link_tour_block on tour_id=link_tour_block.l_tour_id
left join pages_'.$this->sets['lang'].' on tour_link=page_link
left join pages_gorussia on page_id=page_link
left join link_tour_activity on tour_id=link_tour_activity.l_tour_id
left join season on tour_season_id=season_id
where page_show_'.$this->sets['lang'].'="y" and
l_block_id is not NULL and
l_act_id='.$this->sets['folders'][3].'
order by page_sort_id asc';
$this->tourPrepare($db->sql2array($sql, 'tour_id'));
}
else return header('Location: /');
break;
case 'region':
if(isset($this->sets['folders'][3]) && is_numeric($this->sets['folders'][3])){
$sql='select tour_id, tour_img, tour_dif_id,
tour_days, tour_price1'.$this->curfield.' as price, tour_super,
page_dir,
page_title as tour_title,
tour_desc_'.$this->sets['lang'].' as tour_desc,
season_'.$this->sets['lang'].' as season_title, season_img
from tours inner join link_tour_block on tour_id=link_tour_block.l_tour_id
left join pages_'.$this->sets['lang'].' on tour_link=page_link
left join pages_gorussia on page_id=page_link
left join link_tour_region on tour_id=link_tour_region.l_tour_id
left join season on tour_season_id=season_id
where page_show_'.$this->sets['lang'].'="y" and
l_block_id is not NULL and
l_region_id='.$this->sets['folders'][3].'
order by page_sort_id asc';
$this->tourPrepare($db->sql2array($sql, 'tour_id'));
}
else return header('Location: /');
break;
}
$this->template='tour_search.tpl';
}
function renew_password(){
global $vars, $db;
$translate=array(
'en'=>array(
'data_saved'=>'Data saved',
'data_not_saved'=>'Error. Try again',
'customer_not_found'=>'Customer not found!'
),
'es'=>array(
'data_saved'=>'Datos guardados.',
'data_not_saved'=>'Error. Inténtalo de nuevo',
'customer_not_found'=>'Cliente no encontrado.'
),
'us'=>array(
'data_saved'=>'Data saved',
'data_not_saved'=>'Error. Try again',
'customer_not_found'=>'Customer not found!'
),
'fr'=>array(
'data_saved'=>'Sauver',
'data_not_saved'=>'Erreur ! Réessayez',
'customer_not_found'=>'Client pas trouvé !'
),
'de'=>array(
'data_saved'=>'Daten gespeichert',
'data_not_saved'=>'Fehler! Versuchen Sie es erneut',
'customer_not_found'=>'Kunde nicht gefunden!'
),
);
setDBConnection('tms');
$vars['new_password']=trim($vars['new_password']);
if(isset($vars['cus_id']) && is_numeric($vars['cus_id']) && !empty($vars['new_password'])){
// set password
$sql=sprintf("
update tms_client set
cus_pass='%s',
cus_hash=md5('%s')
where cus_id=%d
",
$vars['new_password'],
$vars['new_password'],
$vars['cus_id']);
$res=$db->query($sql);
if(!$res){
$this->errors[]=$translate[$this->sets['lang']]['data_not_saved'].$sql;
}
else{
$this->errors[]=$translate[$this->sets['lang']]['data_saved'];
}
return $this->header('/'.$this->sets['lang'].'/customer/login.html');
die();
}
$client=$db->sql2rec('
select cus_id, cus_email, cus_fname, cus_lname
from tms_client
where md5(concat("GR", cus_email))="'.trim($this->sets['item']).'"
');
if(!$client){
$this->errors[]=$translate[$this->sets['lang']]['customer_not_found'];
return $this->header('/'.$this->sets['lang'].'/customer/login.html');
}
$this->assign('client', $client);
$this->template='customer/renew_password.tpl';
setDBConnection($this->site);
}
}
?>